import { request } from "@/utils/service"
import type * as Team from "./types/team"
import axios from "axios"
import { getToken } from "@/utils/cache/cookies"
const baseURL = import.meta.env.VITE_BASE_API
// 查
export function getTeamDataApi(params: Team.getTeam) {
  return request({
    url: "team/query",
    method: "get",
    params
  })
}
// 根据token查部门下的团队
export function getqueryTeamName(params: any) {
  return request({
    url: "/team/queryTeamName",
    method: "get",
    params
  })
}
// 增加
export function createTeamDataApi(data: Team.addTeamName) {
  return request({
    url: "team/add",
    method: "post",
    data
  })
}
// 删除
export function delTeamDataApi(id: string) {
  return request({
    url: "team/del",
    method: "delete",
    params: {
      id
    }
  })
}
// 改
export function putTeamDataApi(data: Team.putTeamData) {
  return request({
    url: "team/update",
    method: "put",
    data
  })
}

/** 部门增 */
export function addDepartment(data: Team.addTeamName) {
  return request({
    url: "department/add",
    method: "post",
    data
  })
}
// 查
export function getDepartment(params: Team.getTeam) {
  return request({
    url: "department/query",
    method: "get",
    params
  })
}
// 删除
export function delDepartment(id: string) {
  return request({
    url: "department/del",
    method: "delete",
    params: {
      id
    }
  })
}
// 改
export function putDepartment(data: Team.putTeamData) {
  return request({
    url: "department/update",
    method: "put",
    data
  })
}
// 团队下载
export function rechargeRecord(data: any) {
  return axios({
    url: `${baseURL}/team/downTeam`,
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    responseType: "blob",
    data
  })
}
